<%@ include file="header.jsp" %>
<%@ page import="Model.OtherUser.Friends" %>
<%@ page import="Model.OtherUser.Group" %>
<%@ page import="java.util.ArrayList" %>
<%
	int profileID = -1;
	if (request.getParameter("id")!=null)
		profileID = Integer.parseInt(request.getParameter("id")); 
	 if (User.getName(profileID) == null){
		 profileID = userID;
	 }
	 
	 boolean myPage = profileID==userID;
	 ArrayList<Group> groups = Friends.getGroups(profileID);
	 
%>
	<h1 id="title"><%=User.getName(profileID)%>'s Friends</h1>
    <!-- Three columns -->
    <div class="content box">
    
        <div class="content-in box">
        
	
	<div class=friendsContent1>
	<br />
	<%if (myPage){ %>
	<form action="/UBCDatingServer/movefriend" method="post">
	<%} %>
	    <input type="hidden" name="userID" value="<%=userID%>"/>
		<%for(int i=0; i<groups.size();i++){
			Group thisgroup = groups.get(i);%>
			<%=thisgroup.groupName %>
			<br />
			<br />
			<%for(int j=0; j<thisgroup.users.size();j++){%>
				<%int thisuser = thisgroup.users.get(j);%>
				<%if (myPage){ %><input type="checkbox" name="friend" value="<%=thisuser %>" /><%} %>
				<img src="userprofiles/<%=thisuser%>.jpg" width="50" height="50"> 
				<a href="profile.jsp?id=<%=thisuser%>"><%=User.getName(thisuser) %></a>
		<br />
		<br />
			<%} %>
		<%}%>
		<%if (myPage){ %>
		Moved friend to:
		<select name="group">
		<%for(int i=0; i<groups.size();i++){
			Group thisgroup = groups.get(i);%>
			<option value="<%=thisgroup.groupName %>"><%=thisgroup.groupName %></option>
			
		<%} %>
		</select>
		<input type="submit" value="Move" class="input-submit" name="button"/><br />
		<input type="text" size="30" class="input" name="newgroup"/>
		<input type="submit" value="New" class="input-submit" name="button"/>
	</form>
	
	
	
	
	<%} %>
	<br/>
	<br />
	</div>
            <h2><!-- /col50 -->            </h2>
            <div class="fix"></div>

        </div> <!-- /content-in -->
        
        <div class="content-bottom"></div>

    </div> <!-- /content -->
<%@ include file="footer.jsp" %>